<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="客户ID" prop="cid">
        <el-input
          v-model="queryParams.cid"
          placeholder="请输入客户ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
<!--      <el-form-item label="客户名称" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="店铺名称" prop="company">
        <el-input
          v-model="queryParams.company"
          placeholder="请输入店铺名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="电话" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

<!--    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['energize:device_info:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['energize:device_info:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['energize:device_info:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['energize:device_info:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>-->

    <el-table v-loading="loading" :data="device_infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="设备唯一ID" align="center" prop="id" />
<!--      <el-table-column label="设备属主ID,自助终端的父设备" align="center" prop="pid" />-->
<!--      <el-table-column label="设备类型" align="center" prop="deviceType" />-->
<!--      <el-table-column label="设备标识符" align="center" prop="deviceId" />-->
<!--      <el-table-column label="设备版本号" align="center" prop="deviceVersion" />-->
      <el-table-column label="客户ID" align="center" prop="cid" />
<!--      <el-table-column label="${comment}" align="center" prop="fid" />-->
<!--      <el-table-column label="客户名称" align="center" prop="clientName" />-->
<!--      <el-table-column label="装机时间" align="center" prop="registTime" />-->
<!--      <el-table-column label="硬盘序列号，实际包含除MAC地址之外的硬件标识" align="center" prop="harddiskId" />-->
<!--      <el-table-column label="设备地址" align="center" prop="macAddress" />-->
<!--      <el-table-column label="${comment}" align="center" prop="realMacAddress" />-->
<!--      <el-table-column label="sn码" align="center" prop="snCode" />-->
      <el-table-column label="店铺名称" align="center" prop="company" />
      <el-table-column label="地址" align="center" prop="address" />
      <el-table-column label="电话" align="center" prop="phone" />
<!--      <el-table-column label="开门时间" align="center" prop="openTime" />-->
<!--      <el-table-column label="关门时间" align="center" prop="closeTime" />-->
<!--&lt;!&ndash;      <el-table-column label="是否外送" align="center" prop="delivery" />-->
<!--      <el-table-column label="外送范围" align="center" prop="deliverRange" />-->
<!--      <el-table-column label="起送价" align="center" prop="deliverLimit" />&ndash;&gt;-->
<!--      <el-table-column label="运费" align="center" prop="deliverCost" />-->
<!--      <el-table-column label="商店LOGO" align="center" prop="logo" />-->
<!--      <el-table-column label="推荐人" align="center" prop="referrer" />-->
<!--      <el-table-column label="经度" align="center" prop="lng" />-->
<!--      <el-table-column label="纬度" align="center" prop="lat" />-->
<!--      <el-table-column label="经纬度字符串" align="center" prop="geohash" />-->
<!--      <el-table-column label="评星" align="center" prop="grade" />-->
<!--      <el-table-column label="机器启用" align="center" prop="switch" />-->
<!--      <el-table-column label="省" align="center" prop="province" />-->
<!--      <el-table-column label="市" align="center" prop="city" />-->
<!--      <el-table-column label="区" align="center" prop="area" />-->
<!--      <el-table-column label="行业类别ID-->
<!--1便利店-->
<!--2蔬果生鲜-->
<!--3通讯器材-->
<!--&lt;!&ndash;4五金材料5:餐饮类" align="center" prop="industryId" />&ndash;&gt;-->
<!--      <el-table-column label="商品库存预警阀值" align="center" prop="stockTrigger" />-->
<!--      <el-table-column label="保质期阀值" align="center" prop="produceTrigger" />-->
<!--      <el-table-column label="是否测试机0否1是" align="center" prop="isTest" />-->
<!--      <el-table-column label="店铺门头信息" align="center" prop="header" />-->
<!--      <el-table-column label="注释" align="center" prop="remark" />-->
<!--      <el-table-column label="无库存模式" align="center" prop="unStock" />-->
<!--      <el-table-column label="烟草无库存模式，1-是，0-否" align="center" prop="tobaccoUnStock" />-->
<!--      <el-table-column label="卷烟商城订单是否自动入库" align="center" prop="jyAutoInStock" />-->
<!--      <el-table-column label="代理人" align="center" prop="agent" />-->
<!--      <el-table-column label="分区职员ID(代理人)" align="center" prop="fqStaffId" />-->
<!--      <el-table-column label="模式，1默认离线，2在线，" align="center" prop="mode" />
      <el-table-column label="平板类型，1：直接付2：视付通" align="center" prop="appType" />
      <el-table-column label="机器类型0平板1商通2顶尖不带称3顶尖带称,4-普通双屏,5-新大陆,6-宝盈" align="center" prop="machineType" />
      <el-table-column label="是否删除" align="center" prop="isDel" />
      <el-table-column label="是否加盟店，1：不是，2是" align="center" prop="isFranchise" />
      <el-table-column label="零钱大作战每次抽奖的返利比率，0.1即返利10%" align="center" prop="lingqianRate" />-->
<!--      <el-table-column label="最后一次登录时间" align="center" prop="lastLoginTime" />-->
<!--      <el-table-column label="是否回收,1-是,0-否" align="center" prop="isRecycle" />
      <el-table-column label="是否为B2C商城机" align="center" prop="isB2c" />
      <el-table-column label="对应意视科技那边探针店铺的id，0-标识未添加到探针" align="center" prop="insightShopId" />
      <el-table-column label="合作期限,0-不限,过期不更新版本,没有外卖" align="center" prop="cooperationPeriod" />
      <el-table-column label="更换次数" align="center" prop="changeCount" />
      <el-table-column label="商店类型1普通商店2直营店" align="center" prop="storeType" />
      <el-table-column label="店铺内购商品是否可退：1可退2不可退" align="center" prop="storeIsReturn" />-->
<!--      <el-table-column label="设备登录唯一码" align="center" prop="androidId" />-->
<!--      <el-table-column label="专业版到期时间,-1永久" align="center" prop="expireTime" />
      <el-table-column label="单据是否需要审核0否1是" align="center" prop="isNeedAuditBill" />-->
      <el-table-column label="烟草许可证号" align="center" prop="tobaccoLicense" />
<!--      <el-table-column label="购买类型:1-试用版,2-专业版,3-免费版" align="center" prop="rechargeType" />
      <el-table-column label="购买类型:1-试用版,2-专业版,3-免费版" align="center" prop="purchaseType" />-->
<!--      <el-table-column label="经验" align="center" prop="exp" />-->
<!--      <el-table-column label="积分" align="center" prop="score" />-->
<!--      <el-table-column label="添加时间" align="center" prop="createdAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最后更新" align="center" prop="updatedAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updatedAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="${comment}" align="center" prop="manageUnitUuid" />-->
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['energize:device_info:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['energize:device_info:remove']"
          >删除</el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改设备信息对话框 -->
<!--    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="设备属主ID,自助终端的父设备" prop="pid">
          <el-input v-model="form.pid" placeholder="请输入设备属主ID,自助终端的父设备" />
        </el-form-item>
        <el-form-item label="设备标识符" prop="deviceId">
          <el-input v-model="form.deviceId" placeholder="请输入设备标识符" />
        </el-form-item>
        <el-form-item label="设备版本号" prop="deviceVersion">
          <el-input v-model="form.deviceVersion" placeholder="请输入设备版本号" />
        </el-form-item>
        <el-form-item label="客户ID" prop="cid">
          <el-input v-model="form.cid" placeholder="请输入客户ID" />
        </el-form-item>
        <el-form-item label="${comment}" prop="fid">
          <el-input v-model="form.fid" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="客户名称" prop="clientName">
          <el-input v-model="form.clientName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="装机时间" prop="registTime">
          <el-input v-model="form.registTime" placeholder="请输入装机时间" />
        </el-form-item>
        <el-form-item label="硬盘序列号，实际包含除MAC地址之外的硬件标识" prop="harddiskId">
          <el-input v-model="form.harddiskId" placeholder="请输入硬盘序列号，实际包含除MAC地址之外的硬件标识" />
        </el-form-item>
        <el-form-item label="设备地址" prop="macAddress">
          <el-input v-model="form.macAddress" placeholder="请输入设备地址" />
        </el-form-item>
        <el-form-item label="${comment}" prop="realMacAddress">
          <el-input v-model="form.realMacAddress" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="sn码" prop="snCode">
          <el-input v-model="form.snCode" placeholder="请输入sn码" />
        </el-form-item>
        <el-form-item label="店铺名称" prop="company">
          <el-input v-model="form.company" placeholder="请输入店铺名称" />
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址" />
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="开门时间" prop="openTime">
          <el-input v-model="form.openTime" placeholder="请输入开门时间" />
        </el-form-item>
        <el-form-item label="关门时间" prop="closeTime">
          <el-input v-model="form.closeTime" placeholder="请输入关门时间" />
        </el-form-item>
        <el-form-item label="是否外送" prop="delivery">
          <el-input v-model="form.delivery" placeholder="请输入是否外送" />
        </el-form-item>
        <el-form-item label="外送范围" prop="deliverRange">
          <el-input v-model="form.deliverRange" placeholder="请输入外送范围" />
        </el-form-item>
        <el-form-item label="起送价" prop="deliverLimit">
          <el-input v-model="form.deliverLimit" placeholder="请输入起送价" />
        </el-form-item>
        <el-form-item label="运费" prop="deliverCost">
          <el-input v-model="form.deliverCost" placeholder="请输入运费" />
        </el-form-item>
        <el-form-item label="商店LOGO" prop="logo">
          <el-input v-model="form.logo" placeholder="请输入商店LOGO" />
        </el-form-item>
        <el-form-item label="推荐人" prop="referrer">
          <el-input v-model="form.referrer" placeholder="请输入推荐人" />
        </el-form-item>
        <el-form-item label="经度" prop="lng">
          <el-input v-model="form.lng" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="纬度" prop="lat">
          <el-input v-model="form.lat" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="经纬度字符串" prop="geohash">
          <el-input v-model="form.geohash" placeholder="请输入经纬度字符串" />
        </el-form-item>
        <el-form-item label="评星" prop="grade">
          <el-input v-model="form.grade" placeholder="请输入评星" />
        </el-form-item>
        <el-form-item label="机器启用" prop="switch">
          <el-input v-model="form.switch" placeholder="请输入机器启用" />
        </el-form-item>
        <el-form-item label="省" prop="province">
          <el-input v-model="form.province" placeholder="请输入省" />
        </el-form-item>
        <el-form-item label="市" prop="city">
          <el-input v-model="form.city" placeholder="请输入市" />
        </el-form-item>
        <el-form-item label="区" prop="area">
          <el-input v-model="form.area" placeholder="请输入区" />
        </el-form-item>
        <el-form-item label="行业类别ID
1便利店
2蔬果生鲜
3通讯器材
4五金材料5:餐饮类" prop="industryId">
          <el-input v-model="form.industryId" placeholder="请输入行业类别ID
1便利店
2蔬果生鲜
3通讯器材
4五金材料5:餐饮类" />
        </el-form-item>
        <el-form-item label="商品库存预警阀值" prop="stockTrigger">
          <el-input v-model="form.stockTrigger" placeholder="请输入商品库存预警阀值" />
        </el-form-item>
        <el-form-item label="保质期阀值" prop="produceTrigger">
          <el-input v-model="form.produceTrigger" placeholder="请输入保质期阀值" />
        </el-form-item>
        <el-form-item label="是否测试机0否1是" prop="isTest">
          <el-input v-model="form.isTest" placeholder="请输入是否测试机0否1是" />
        </el-form-item>
        <el-form-item label="店铺门头信息" prop="header">
          <el-input v-model="form.header" placeholder="请输入店铺门头信息" />
        </el-form-item>
        <el-form-item label="注释" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入注释" />
        </el-form-item>
        <el-form-item label="无库存模式" prop="unStock">
          <el-input v-model="form.unStock" placeholder="请输入无库存模式" />
        </el-form-item>
        <el-form-item label="烟草无库存模式，1-是，0-否" prop="tobaccoUnStock">
          <el-input v-model="form.tobaccoUnStock" placeholder="请输入烟草无库存模式，1-是，0-否" />
        </el-form-item>
        <el-form-item label="卷烟商城订单是否自动入库" prop="jyAutoInStock">
          <el-input v-model="form.jyAutoInStock" placeholder="请输入卷烟商城订单是否自动入库" />
        </el-form-item>
        <el-form-item label="代理人" prop="agent">
          <el-input v-model="form.agent" placeholder="请输入代理人" />
        </el-form-item>
        <el-form-item label="分区职员ID(代理人)" prop="fqStaffId">
          <el-input v-model="form.fqStaffId" placeholder="请输入分区职员ID(代理人)" />
        </el-form-item>
        <el-form-item label="模式，1默认离线，2在线，" prop="mode">
          <el-input v-model="form.mode" placeholder="请输入模式，1默认离线，2在线，" />
        </el-form-item>
        <el-form-item label="是否删除" prop="isDel">
          <el-input v-model="form.isDel" placeholder="请输入是否删除" />
        </el-form-item>
        <el-form-item label="是否加盟店，1：不是，2是" prop="isFranchise">
          <el-input v-model="form.isFranchise" placeholder="请输入是否加盟店，1：不是，2是" />
        </el-form-item>
        <el-form-item label="零钱大作战每次抽奖的返利比率，0.1即返利10%" prop="lingqianRate">
          <el-input v-model="form.lingqianRate" placeholder="请输入零钱大作战每次抽奖的返利比率，0.1即返利10%" />
        </el-form-item>
        <el-form-item label="是否回收,1-是,0-否" prop="isRecycle">
          <el-input v-model="form.isRecycle" placeholder="请输入是否回收,1-是,0-否" />
        </el-form-item>
        <el-form-item label="是否为B2C商城机" prop="isB2c">
          <el-input v-model="form.isB2c" placeholder="请输入是否为B2C商城机" />
        </el-form-item>
        <el-form-item label="对应意视科技那边探针店铺的id，0-标识未添加到探针" prop="insightShopId">
          <el-input v-model="form.insightShopId" placeholder="请输入对应意视科技那边探针店铺的id，0-标识未添加到探针" />
        </el-form-item>
        <el-form-item label="更换次数" prop="changeCount">
          <el-input v-model="form.changeCount" placeholder="请输入更换次数" />
        </el-form-item>
        <el-form-item label="店铺内购商品是否可退：1可退2不可退" prop="storeIsReturn">
          <el-input v-model="form.storeIsReturn" placeholder="请输入店铺内购商品是否可退：1可退2不可退" />
        </el-form-item>
        <el-form-item label="设备登录唯一码" prop="androidId">
          <el-input v-model="form.androidId" placeholder="请输入设备登录唯一码" />
        </el-form-item>
        <el-form-item label="专业版到期时间,-1永久" prop="expireTime">
          <el-input v-model="form.expireTime" placeholder="请输入专业版到期时间,-1永久" />
        </el-form-item>
        <el-form-item label="单据是否需要审核0否1是" prop="isNeedAuditBill">
          <el-input v-model="form.isNeedAuditBill" placeholder="请输入单据是否需要审核0否1是" />
        </el-form-item>
        <el-form-item label="烟草许可证号" prop="tobaccoLicense">
          <el-input v-model="form.tobaccoLicense" placeholder="请输入烟草许可证号" />
        </el-form-item>
        <el-form-item label="经验" prop="exp">
          <el-input v-model="form.exp" placeholder="请输入经验" />
        </el-form-item>
        <el-form-item label="积分" prop="score">
          <el-input v-model="form.score" placeholder="请输入积分" />
        </el-form-item>
        <el-form-item label="添加时间" prop="createdAt">
          <el-date-picker clearable
            v-model="form.createdAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择添加时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后更新" prop="updatedAt">
          <el-date-picker clearable
            v-model="form.updatedAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后更新">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="${comment}" prop="manageUnitUuid">
          <el-input v-model="form.manageUnitUuid" placeholder="请输入${comment}" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>-->
  </div>
</template>

<script>
import { listDevice_info, getDevice_info, delDevice_info, addDevice_info, updateDevice_info } from "@/api/energize/device_info";

export default {
  name: "Device_info",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 设备信息表格数据
      device_infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // $comment时间范围
      daterangeCreatedAt: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cid: null,
        clientName: null,
        company: null,
        address: null,
        phone: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        pid: [
          { required: true, message: "设备属主ID,自助终端的父设备不能为空", trigger: "blur" }
        ],
        deviceType: [
          { required: true, message: "设备类型", trigger: "change" }
        ],
        cid: [
          { required: true, message: "客户ID不能为空", trigger: "blur" }
        ],
        clientName: [
          { required: true, message: "客户名称不能为空", trigger: "blur" }
        ],
        registTime: [
          { required: true, message: "装机时间不能为空", trigger: "blur" }
        ],
        macAddress: [
          { required: true, message: "设备地址不能为空", trigger: "blur" }
        ],
        company: [
          { required: true, message: "店铺名称不能为空", trigger: "blur" }
        ],
        address: [
          { required: true, message: "地址不能为空", trigger: "blur" }
        ],
        phone: [
          { required: true, message: "电话不能为空", trigger: "blur" }
        ],
        openTime: [
          { required: true, message: "开门时间不能为空", trigger: "blur" }
        ],
        closeTime: [
          { required: true, message: "关门时间不能为空", trigger: "blur" }
        ],
        delivery: [
          { required: true, message: "是否外送不能为空", trigger: "blur" }
        ],
        deliverRange: [
          { required: true, message: "外送范围不能为空", trigger: "blur" }
        ],
        deliverLimit: [
          { required: true, message: "起送价不能为空", trigger: "blur" }
        ],
        deliverCost: [
          { required: true, message: "运费不能为空", trigger: "blur" }
        ],
        grade: [
          { required: true, message: "评星不能为空", trigger: "blur" }
        ],
        switch: [
          { required: true, message: "机器启用不能为空", trigger: "blur" }
        ],
        province: [
          { required: true, message: "省不能为空", trigger: "blur" }
        ],
        city: [
          { required: true, message: "市不能为空", trigger: "blur" }
        ],
        area: [
          { required: true, message: "区不能为空", trigger: "blur" }
        ],
        industryId: [
          { required: true, message: "行业类别", trigger: "blur" }
        ],
        stockTrigger: [
          { required: true, message: "商品库存预警阀值不能为空", trigger: "blur" }
        ],
        produceTrigger: [
          { required: true, message: "保质期阀值不能为空", trigger: "blur" }
        ],
        isTest: [
          { required: true, message: "是否测试机0否1是不能为空", trigger: "blur" }
        ],
        header: [
          { required: true, message: "店铺门头信息不能为空", trigger: "blur" }
        ],
        remark: [
          { required: true, message: "注释不能为空", trigger: "blur" }
        ],
        unStock: [
          { required: true, message: "无库存模式不能为空", trigger: "blur" }
        ],
        tobaccoUnStock: [
          { required: true, message: "烟草无库存模式，1-是，0-否不能为空", trigger: "blur" }
        ],
        jyAutoInStock: [
          { required: true, message: "卷烟商城订单是否自动入库不能为空", trigger: "blur" }
        ],
        fqStaffId: [
          { required: true, message: "分区职员ID(代理人)不能为空", trigger: "blur" }
        ],
        mode: [
          { required: true, message: "模式，1默认离线，2在线，不能为空", trigger: "blur" }
        ],
        machineType: [
          { required: true, message: "机器类型0平板1商通2顶尖不带称3顶尖带称,4-普通双屏,5-新大陆,6-宝盈不能为空", trigger: "change" }
        ],
        isDel: [
          { required: true, message: "是否删除不能为空", trigger: "blur" }
        ],
        lingqianRate: [
          { required: true, message: "零钱大作战每次抽奖的返利比率，0.1即返利10%不能为空", trigger: "blur" }
        ],
        isRecycle: [
          { required: true, message: "是否回收,1-是,0-否不能为空", trigger: "blur" }
        ],
        isB2c: [
          { required: true, message: "是否为B2C商城机不能为空", trigger: "blur" }
        ],
        cooperationPeriod: [
          { required: true, message: "合作期限,0-不限,过期不更新版本,没有外卖不能为空", trigger: "blur" }
        ],
        changeCount: [
          { required: true, message: "更换次数不能为空", trigger: "blur" }
        ],
        storeIsReturn: [
          { required: true, message: "店铺内购商品是否可退：1可退2不可退不能为空", trigger: "blur" }
        ],
        androidId: [
          { required: true, message: "设备登录唯一码不能为空", trigger: "blur" }
        ],
        expireTime: [
          { required: true, message: "专业版到期时间,-1永久不能为空", trigger: "blur" }
        ],
        isNeedAuditBill: [
          { required: true, message: "单据是否需要审核0否1是不能为空", trigger: "blur" }
        ],
        purchaseType: [
          { required: true, message: "购买类型:1-试用版,2-专业版,3-免费版不能为空", trigger: "change" }
        ],
        exp: [
          { required: true, message: "经验不能为空", trigger: "blur" }
        ],
        score: [
          { required: true, message: "积分不能为空", trigger: "blur" }
        ],
        createdAt: [
          { required: true, message: "添加时间不能为空", trigger: "blur" }
        ],
        updatedAt: [
          { required: true, message: "最后更新不能为空", trigger: "blur" }
        ],
        manageUnitUuid: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询设备信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeCreatedAt && '' != this.daterangeCreatedAt) {
        this.queryParams.params["beginCreatedAt"] = this.daterangeCreatedAt[0];
        this.queryParams.params["endCreatedAt"] = this.daterangeCreatedAt[1];
      }
      listDevice_info(this.queryParams).then(response => {
        this.device_infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        pid: null,
        deviceType: null,
        deviceId: null,
        deviceVersion: null,
        cid: null,
        fid: null,
        clientName: null,
        registTime: null,
        harddiskId: null,
        macAddress: null,
        realMacAddress: null,
        snCode: null,
        company: null,
        address: null,
        phone: null,
        openTime: null,
        closeTime: null,
        delivery: null,
        deliverRange: null,
        deliverLimit: null,
        deliverCost: null,
        logo: null,
        referrer: null,
        lng: null,
        lat: null,
        geohash: null,
        grade: null,
        switch: null,
        province: null,
        city: null,
        area: null,
        industryId: null,
        stockTrigger: null,
        produceTrigger: null,
        isTest: null,
        header: null,
        remark: null,
        unStock: null,
        tobaccoUnStock: null,
        jyAutoInStock: null,
        agent: null,
        fqStaffId: null,
        mode: null,
        appType: null,
        machineType: null,
        isDel: null,
        isFranchise: null,
        lingqianRate: null,
        lastLoginTime: null,
        isRecycle: null,
        isB2c: null,
        insightShopId: null,
        cooperationPeriod: null,
        changeCount: null,
        storeType: null,
        storeIsReturn: null,
        androidId: null,
        expireTime: null,
        isNeedAuditBill: null,
        tobaccoLicense: null,
        rechargeType: null,
        purchaseType: null,
        exp: null,
        score: null,
        createdAt: null,
        updatedAt: null,
        manageUnitUuid: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCreatedAt = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加设备信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getDevice_info(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改设备信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateDevice_info(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDevice_info(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除设备信息编号为"' + ids + '"的数据项？').then(function() {
        return delDevice_info(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('energize/device_info/export', {
        ...this.queryParams
      }, `device_info_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
